{include file="public/header" /}
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 管理员列表</strong></div>
    <div class="padding border-bottom">
        <a class="button border-yellow" href="{:U('admin/add')}"><span class="icon-plus-square-o"></span>添加</a>
    </div>
    <table id="content_table" class="table table-hover text-center">
        <tr>
            <th width="5%">ID</th>
            <th width="15%">管理员账号</th>
            <th width="10%">权限组</th>
            <th width="10%">操作</th>
        </tr>

        {foreach name='list' item='val'}
        <tr id="del_{$val.id}">
            <td> {$val.id}</td>
            <td>{$val.username}</td>
            <td>{$val.role_name}</td>
            <td><div class="button-group">
                <a class="button border-main" href="{:U('admin/edit',['id'=>$val['id']])}"><span class="icon-edit"></span>编辑</a> <a class="button border-red" href="javascript:void(0)" onclick="del('{$val.id}')"><span class="icon-trash-o"></span>删除</a> </div></td>
        </tr>

        {/foreach}
    </table>

</div>
{$page}


<script>
    function del(ids){
        if(ids==''){
            layer.msg('参数不能为空',{icon:2});
        }else{
            layer.confirm('您确定要删除吗？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                $.ajax({
                    type:"get",
                    url:"{:U('admin/ajaxDelete')}",
                    data:{id:ids},
                    dataType:'json',
                    success:function(data){
                        if(data.res==1){
                            layer.msg(data.msg, {icon:1}, function(){
                                $("#content_table").find("#del_"+ids).remove();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2});
                        }
                    }
                });
            }, function(){
            });
        }
    }

</script>

{include file="public/index_footer" /}